"""
这是函数章节的综合案例
黑马ATM
"""
import os

# 定义一个全局变量money用来记录银行卡余额（默认5_000_000）
money = 5_000_000
# 定义一个全局变量name用来记录客户姓名（启动程序时输入）
# name = ''
name = None
# 定义ATM机的函数
def select_change():
    print(f"Hi,{name},your change is:{money}.")

def save(number):
    global money
    money= money + number
    print(f"{number} Saved Successfully!")
    select_change()

def pick(number):
    global money
    if money >= number:
        money = money - number
        print(f"{number} Picked Successfully!")
        select_change()
    else:
        print("Insufficient Funds!")

def main_mane():
    # Python中清屏控制台的函数
    print('\n\n\n\n\n\n\n\n\n\n\n')
    print(f'Welcome, Dear {name}.')
    print('This is Heima ATM.')
    print('--------------------------------------------------------')
    print('If you want to select your change, please enter 1:')
    print('If you want to save your money, please enter 2:')
    print('If you want to pick your money, please enter 3:')
    print('If you want to exit, please enter 4:')
    print('--------------------------------------------------------')
    print('Attention! Dou\'t enter wrong number or you will exit automatically!')


if __name__ == '__main__':
    name = input("Please enter your name:")
    while True:
        main_mane()
        choice = int(input("Please enter your choice:"))
        if choice == 1:
            select_change()
            input('Enter any to continue...')
            continue
        elif choice == 2:
            save(int(input("Please enter your money:")))
            input('Enter any to continue...')
            continue
        elif choice == 3:
            pick(int(input("Please enter your money:")))
            input('Enter any to continue...')
            continue
        else:
            print('Exited Now!')
            break